package com.jf.nep.scene.object;

import org.lwjgl.util.vector.Vector3f;
import org.lwjgl.util.vector.Vector4f;

import com.jf.nep.render.Mesh;
import com.jf.nep.render.Vertex;

public class FloorTile implements Mesh {
    
    private Vertex[] vertices;
    private byte[] indices;

    public FloorTile() {
        Vector4f p0 = new Vector4f(-1, 0, -1,1);
        Vector4f p1 = new Vector4f(-1, 0, 1,1);
        Vector4f p2 = new Vector4f(1, 0, 1,1);
        
        Vector3f u = new Vector3f(p1.x-p0.x,p1.y-p0.y,p1.z-p0.z);        
        Vector3f v = new Vector3f(p2.x-p0.x,p2.y-p0.y,p2.z-p0.z);
        
        Vector3f n = new Vector3f();
        Vector3f.cross(u, v, n);
        n.normalise();
        Vector4f n4 = new Vector4f(n.x,n.y,n.z,1);
        
        Vertex v0 = new Vertex(p0,n4);
        Vertex v1 = new Vertex(p1,n4);
        Vertex v2 = new Vertex(p2,n4);
        Vertex v3 = new Vertex(new Vector4f(1, 0, -1,1),n4);
        
        vertices = new Vertex[] { v0,v1,v2,v3};
        indices = new byte[] {0,1,2,0,2,3};
    } 
    
    @Override
    public String id() {
        return "floor";
    }

    @Override
    public Vertex[] getVertices() {
        return vertices;
    }

    @Override
    public byte[] getIndices() {
        return indices;
    }

    @Override
    public String getShader() {
        // TODO Auto-generated method stub
        return null;
    }
}
